home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / ambush.tpl next >
Encoding:
Text File  |  2001-07-16  |  5.6 KB  |  179 lines

  1.  
  2. UIFIELDS
  3. {
  4. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  5. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  6. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  7. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  8. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  9. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  10. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  11.                                                     // and other things.  It indicates a general level of combat experience.
  12. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?
  13.         
  14.  
  15. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  16. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  17. }
  18.  
  19.  
  20. //------------------------------------------------------------------
  21. // NOTE: The fsm name below MUST be changed in order for the
  22. // script to be considered a unique entity!
  23.  
  24. fsm Generic_Ambush : integer;
  25.  
  26.  
  27. //------------------------------------------------------------------
  28.  
  29. // Generic_Ambush:
  30. //   Shuts down, waits until an enemy comes near, and then attacks.
  31.  
  32. //------------------------------------------------------------------
  33.  
  34.  
  35.  
  36. //------------------------------------------------------------------
  37. //     Constants
  38. //------------------------------------------------------------------
  39.  
  40.     const
  41.         #include_ <content\ABLScripts\mwconst.abi>
  42.  
  43. //------------------------------------------------------------------
  44. //     Types
  45. //------------------------------------------------------------------
  46.  
  47.     type
  48.         #include_ <content\ABLScripts\mwtype.abi>
  49.     
  50.  
  51. //------------------------------------------------------------------
  52. //     Variables
  53. //------------------------------------------------------------------
  54.  
  55.     var
  56.         static integer            attackRange;        // At what range do I start shooting?
  57.         static integer            withdrawRange;        // At what range do I withdraw from combat entirely?
  58.                                                                     
  59.         static integer            piloting;            // Piloting skill
  60.         static integer            gunnery;            // Gunnery skill/chance to hit
  61.         static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  62.         static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  63.         static integer             eliteLevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  64.                                                     // and other things.  It indicates a general level of combat experience.
  65.         static integer            attackThrottle;        // My attack throttle
  66.  
  67.          static integer            isShotRadius;        // How far away from me will I detect an enemy shot?
  68.  
  69.         static integer             attackSound;        // The attack sound I play when I first attack
  70.         static integer             deathSound;            // The sound I play when I die
  71.         
  72.         static integer            mood;                // My default mood.
  73.  
  74.         static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  75.  
  76. //------------------------------------------------------------------
  77. //     Init: my initialization function
  78. //------------------------------------------------------------------
  79.  
  80. function Init;
  81.     code
  82.  
  83.         // Variables set by editor
  84.         attackRange        = <attackRange>;
  85.         withdrawRange    = <withdrawRange>;
  86.         speed            = <speed>;
  87.          takeOffDistance    = <takeOffDistance>;
  88.          piloting        = <piloting>;
  89.         gunnery            = <gunnery>;
  90.         minDelay        = <minDelay>;
  91.         maxDelay        = <maxDelay>;
  92.         eliteLevel        = <eliteLevel>;
  93.         isShotRadius    = <isShotRadius>;
  94.     attackThrottle    = <attackThrottle>;
  95.  
  96.  
  97.  
  98.  
  99.         // driver settings
  100.         attackSound        = -1; // no sound
  101.         deathSound        = -1; // no sound
  102.         mood            = NEUTRAL_START;
  103.  
  104.  
  105. endfunction;
  106.  
  107. //------------------------------------------------------------------
  108. //    StartState: my initial state
  109. //------------------------------------------------------------------
  110.  
  111. state StartState;
  112.  
  113.     code
  114.         SetFiringDelay            (ME,minDelay,maxDelay);
  115.         SetIgnoreFriendlyFire    (ME,true);
  116.         SetIsShotRadius            (ME,isShotRadius);
  117.         SetEntropyMood            (ME,mood);
  118.         SetCurMood                (ME,mood);
  119.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  120.         SetAttackThrottle        (ME,attackThrottle);
  121.                 
  122.         if (orderTakeOff(takeOffDistance) == true) then
  123.             trans WaitToAmbushState;
  124.         endif;
  125.  
  126. endstate;            
  127.  
  128. //------------------------------------------------------------------
  129. //    WaitInAmbushState: wait for someone to come close enough to attack
  130. //------------------------------------------------------------------
  131.  
  132. state WaitToAmbushState;
  133.     code
  134.         Shutdown(ME);
  135.  
  136.         if (FindEnemy(attackrange,FT_DEFAULT)) then
  137.             trans AttackState;
  138.         endif;
  139.  
  140. endstate;
  141.  
  142. //------------------------------------------------------------------
  143. //    AttackState: the ambush is over -- let's kick some ass!
  144. //------------------------------------------------------------------
  145.  
  146. state AttackState;
  147.     code
  148.         if (LeaveAttackState(withdrawRange)) then
  149.             trans WaitToAmbushState;
  150.         endif;
  151.  
  152.         if (attackSound <> -1) then    
  153.             PlaySoundOnce(attackSound);
  154.         endif;
  155.  
  156.         Startup(ME);
  157.  
  158.         OrderAttack(TRUE);
  159.  
  160. endstate;
  161.  
  162. //------------------------------------------------------------------
  163. //    DeadState: OK, I kicked the bucket.
  164. //------------------------------------------------------------------
  165.  
  166. state DeadState;
  167.     code
  168.         if (deathSound <> -1) then    
  169.             PlaySoundOnce(deathSound);
  170.         endif;        
  171.  
  172.         orderDie;
  173.  
  174. endstate;
  175.  
  176.  
  177. endfsm.
  178.  
  179.